package test;

import java.util.regex.*;

class regexSample 
{
   public static void main(String args[]) 
   {
      //Input the string for validation
      String email = "\n xyz@hotmail.com";
System.out.println(email);
      //Set the email pattern string
      Pattern p = Pattern.compile(".+@.+\\.[a-z]+");

//      for(String line : email.split("\n")){
//    	  Matcher m = p.matcher(line.trim());
//    	  if(m.matches()){
//    		  System.out.println(m.group());
//    	  }
//      }
      
      //Match the given string with the pattern
      Matcher m = p.matcher(email);

      //check whether match is found 
      boolean matchFound = m.matches();

      System.out.println(m.groupCount());
      
      if (matchFound)
        System.out.println("Valid Email Id.");
      else
        System.out.println("Invalid Email Id.");
   }
}